Repository navigation
Add SegmentedControl component - #354
Open
georgerichmond wants to merge 9 commits into
Open
georgerichmond wants to merge 9 commits into
georgerichmond wants to merge 9 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dependency Compatibility Matrix
|
Use the designer's segmented control terminology across the public API, package exports, tokens, documentation and examples. Match the Small / Condensed design and cover stable sizing when selection changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Follow React Spectrum's SegmentedControl API: selectedKey, defaultSelectedKey and onSelectionChange(key); selection cannot be cleared - Remove disabled state (not in Figma) and redundant selected typography tokens - Use 2px focus outline offset, consistent with other components - Trim stories, update docs, sandbox and changeset - Point Figma link to the Design System file - Remove Playwright spec and mock (visual coverage via Chromatic) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Like Tabs, the component relies on React Aria for selection and keyboard behaviour, so drop the CSS/JS examples that duplicated styles.ts and document the available design tokens instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stories, docs and sandbox now use the preview widths (320, 375, 425, 650px) that HtmlPreview offers, with numeric item ids. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change?
Adds
SegmentedControlandSegmentedControlItem(@guardian/stand/SegmentedControl) for choosing one option from a small set of related options, such as the preview widths in HtmlPreview. It is built on React Aria'sToggleButtonGroup/ToggleButton.API follows React Spectrum's SegmentedControl.
selectedKey,defaultSelectedKeyandonSelectionChange(key).Scope: this PR includes only the Figma Small / Condensed text variant. XSmall, the default font width and icon variants can be added later. There is no disabled state because the Figma doesn't have one.
The component still needs design-system review, so it is marked as unverified.
Closes #352.
Question for reviewers
This PR only includes the Small / Condensed text variant, because that's all HtmlPreview needs right now. Should the other Figma variants (XSmall, the default font width and icons) be added in this PR, or in follow-up PRs when something needs them?
Adding them later won't break anything as long as Small / Condensed stays the default.
How to test
Check the SegmentedControl stories and docs in Storybook. Chromatic covers visual changes. In line with other components, there are no Playwright or unit tests.
Images
Figma design example:
Preview widths (default story):
Selected positions: